package com.bole.controller;

import com.bole.dto.user.UserDto;
import com.bole.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/{telePhone}")
    public UserDto getUserByTelephone(@PathVariable("telePhone") String telePhone) {
        try {
            UserDto userDto = userService.getUserByTelePhone(telePhone);
            return userDto;
        } catch (Exception e) {
            e.printStackTrace();
            return new UserDto();
        }
    }

}
